import { get } from 'utils/request.js';
import { config } from 'config.js';


// 获取应用实例
const app = getApp(); //  eslint-disable-line no-undef
let configs = config();
Page({
  data: {
    name: '',
    content: '',
    image_url: '',
    question: '',
    results: '',
    mobile: ''
  },
  async onLoad(options) {
    // 调用应用实例的方法获取全局数
    var id = options.id;
    var that = this;
    get({'path': configs.complainDetail}, {id: id}).then(function(res){
      var tempData = res.data;
      if (tempData.ret == 0) {
        var data = tempData.data;
        that.setData({
          name: data.name,
          content: data.content,
          image_url: data.image_url,
          question: data.question,
          results: data.results,
          mobile: data.mobile
        })
      } else {
        wx.showToast({
          image: require('../../images/com/error.svg'),
          title: ratingData.msg
        })
        return false;
      }
    }, function(res){
      wx.showToast({
        image: require('../../images/com/error.svg'),
        title: res.data.msg
      })
      return false;
    })
  },
  callTap(e){
    var mobile = e.target.dataset.mobile || '';
    if(mobile){
      wx.makePhoneCall({
        phoneNumber: mobile
      })
    }
  }
});
